﻿/**
 * @file menu.c
 * @brief this is a brief description
 * @details this is the detail description.
 * @author fulong 
 * @data 7/31/2014
 * @version 1.0
 * @par Copyright (c):
 * @par First build
 *     version: fulong 
 *     data: 7/31/2014
 */
#include "menu.h"
#include "menu_common.h"
#include "menu_process.h"
#include "../../bsp/board.h"
#ifdef MENU_DEBUG
#include "../../dev/uart.h"
#endif

#ifdef MENU_ENABLE

menu_id_table_struct menu_widget_table;
menu_id_table_index_struct menu_widget_index;
menu_flag_struct menu_flag;
menu_struct cur_menu;
menu_controllable_strcut  menu_controllable;
menu_struct pre_menu;
uint8 old_menu_num;
inner_proc_struct inner_proc_var[ MENU_MAX_COUNT ];
void menu_init(void) {
    uint8 i;
    old_menu_num = 0;
    for (i = 0; i < MENU_MAX_COUNT; i++) {
        inner_proc_var[i].inner_proc_time = 0;
        inner_proc_var[i].inner_proc_type = 0;
    }
    for (i = 0; i < CONTROLLABLE_WIDGET_MAX_LEN; i++) {
        menu_controllable.menu_controllabe_table[i] = 0;
    }
    menu_controllable.menu_controllable_pointer = 0;
    menu_flag.menu_flag_byte = 0;
    menu_widget_create();
    cur_menu.menu_num = 0;
    cur_menu.cur_dis_widget_num = 0;
    pre_menu.menu_num = 0;
    pre_menu.cur_dis_widget_num = 0;
    if (menu_widget_index.menu_count > 1) {
        cur_menu.menu_widget_len = menu_widget_index.menu_table_index[1] - menu_widget_index.menu_table_index[0];
    } else {
        cur_menu.menu_widget_len = menu_widget_table.menu_widget_count;
    }
    pre_menu.menu_widget_len = cur_menu.menu_widget_len;
    get_ctrllable_table_range();
    set_ctrllable_widget_pointer(menu_controllable.right_edge);
}
void menu_display(void) {
    widget_display();
    menu_inner_process();
}
#endif
